package com.qcby.service.impl;

import com.qcby.dao.QuestionDao;
import com.qcby.entity.Question;
import com.qcby.service.QuestionService;
import com.qcby.util.JsonParseOptions;
import org.apache.poi.ss.formula.functions.T;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {
    @Autowired
    private QuestionDao questionDao;
    @Autowired
    private JsonParseOptions jsonParseOptions;
    @Override
    public List<Question> list() {
        List<Question> list = questionDao.list();
        List<Question> options = jsonParseOptions.getOptions(list);
        return options;
    }

    @Override
    public void insertQuestions(List<Question> questionList) {
        questionDao.insertQuestions(questionList);
    }

    @Override
    public List<Question> getByExamId(Integer id) {
        List<Question> list = questionDao.getByExamId(id);
        List<Question> options = jsonParseOptions.getOptions(list);
        return options;
    }

    @Override
    public List<Question> getQuestionTypeAndCount(Integer id) {
        return questionDao.getQuestionTypeAndCount(id);
    }
}
